1. Field of the Invention
The present invention relates to a technology of analyzing digital images and more particularly, to a device of gathering statistics of gray distribution of images and a method thereof.
2. Description of Related Art
A gray histogram (abbreviated as GH) and a gray cumulative percentage graph are important and indispensable information in image processing. In general, the gray histogram is obtained with a probability distribution function (PDF) and the gray cumulative percentage graph is obtained with a cumulative distribution function (CDF). Further illustration on the gray histogram and the gray cumulative percentage graph is provided below.
FIG. 1A is a conventional gray histogram. Referring to FIG. 1A, the gray histogram may be used to determine gray distribution of images, wherein the horizontal axis represents gray values and the vertical axis represents amount of data, i.e. the distribution of the amount of data of each gray value. Take a normally black liquid crystal display as an example. The closer the peak is to the right of the histogram, the more bright data there are and the brighter the entire image will appear. In contrast, the closer the peak is to the left of the histogram, the more dark data there are and the darker the entire image will appear.
FIG. 1B is a conventional gray cumulative percentage graph. Referring to FIG. 1B, the gray cumulative percentage graph may also be used as a tool to determine gray distribution of images. The gray cumulative percentage graph of FIG. 1B is similar to the gray histogram of FIG. 1A. The difference lies in that the horizontal axis of the gray cumulative percentage graph represents gray values and the vertical axis represents cumulative percentages, i.e. the cumulative percentage of each gray value of an image. For example, the gray value 200 illustrates a cumulative percentage which is obtained by dividing the total number of pixels in an image having a gray value under 200 by the total number of pixels in the image.
FIG. 2A is a conventional circuit structure diagram of calculating CDF values. Referring to FIG. 2A, take a monochrome image of having 256 gray levels and a resolution of 1366×768 as an example. A comparing unit 101 has 256 comparators, i.e. 101.0˜101.255. A count unit 103 has 256 counters, i.e. 103.0˜103.255. A division unit 105 has 256 dividers, i.e. 105.0˜105.255. An output unit 107 has 256 registers. i.e. 107.0˜107.255.
First input terminals of the comparators 101.0˜101.255 respectively receive predetermined gray information “0” to “255.” Second input terminals of the comparators 101.0˜101.255 are used to receive gray values of the various data in the image. In light of the above, when the gray values received by the second input terminals of the comparators are lower than or equal to the predetermined gray information of the first input terminals, the said comparators output a high level voltage. Otherwise, the comparators output a low level voltage.
More specifically, when the gray values received at the second input terminals of the comparators 101.0˜101.255 are “50,” the comparators 101.0˜101.50 all output a high level voltage and the comparators 101.51˜101.255 will all output a low level voltage.
The counters 103.0˜103.255 respectively store a count value and may clear the count values based on a clearing signal clear_1. When each of the counters receives a high level voltage “1,” the said counter will add 1 to the count value stored therein according to a clock signal clk_1. The purpose is to keep a count of the amount of data of various gray values in the input image. Furthermore, the counters 103.0˜103.255 may respectively output the abovementioned amount of data to the dividers 105.0˜105.255. Next, the dividers 105.0˜105.255 respectively divide the received amount of data by the total amount of data “1,049,088” in the image. As such, a cumulative percentage of each gray value in the input image may be obtained. Finally, the registers 107.0˜107.255 latch the output values from the dividers 105.0˜105.255 and respectively output the CDF values of the gray values “0”˜“255” according to a clock signal clk_2.
It should be mentioned that the maximum limit of the possible amount of data of each gray value is 1366×768=1,049,088. Therefore, each of the counters in the count unit 103 has to be a counter of 21 bits or more. That is, each counter requires at least 21 registers to implement. In other words, the count unit 103 requires 256×21=5,376 registers. Furthermore, if gray cumulative percentage graphs of two input images are to be retained, the count unit 103 has to use 10,752 registers. In addition, the number of registers required by the count unit 103 rises with the increase in the resolution or the number of gray levels of the input image. In other words, the conventional circuit for calculating CDF values applied in an image of high resolution or high number of gray levels often requires tremendous hardware costs and thus is not suitable for practical use in products.
In light of the above, a conventional solution has been developed which gathers statistics on a combination of gray values. FIG. 2B is another conventional circuit structure diagram of calculating CDF values. Take a monochrome image having 256 gray levels and a resolution of 1366×768 as an example again. FIG. 2B is similar to FIG. 2A with a difference in that a comparing unit 201 has 128 comparators, i.e. 101.1, 101.3, . . . ,101.253, and 101.255. A count unit 203 has 128 counters, i.e. 103.1, 103.3, . . . ,103.253, and 103.255. A division unit 205 has 128 dividers, i.e. 105.1, 105.3, . . . , 105.253, and 105.255. An output unit 207 has 128 registers, i.e. 107.1, 107.3, . . . ,107.253, and 107.255.
An amount of data of gray value under “1” in an image may be obtained through the comparator 101.1, the counter 103.1, the divider 105.1, and the register 107.1. Similarly, an amount of data of gray value under “3” in an image may be obtained through the comparator 101.3, the counter 103.3, the divider 105.3, and the register 107.3. Simply speaking, the approach is to incorporate the calculation of the data of gray value “0” and “1,” the calculation of the data of gray value “2” and “3,” . . . , and the calculation of the data of gray value “254” and “255.” As such, the number of counters used by the count unit 203 decreases to 128 and the number of registers decreases to 2688. However, the approach may only obtain the total amount of data of two gray values and not the amount data of each individual gray value.